import {v4 as uuidv4} from 'uuid'
export const getUUID = () => {
    //生成随机字符串且每次执行不能发生变化 游客身份还要持久存储
    //1、判断本地存储是否由uuid
    let uuid_token = localStorage.getItem('UUIDTOKEN')
    //2、本地存储没有uuid
    if (!uuid_token) {
        //2.1生成uuid
        uuid_token = uuidv4()
        //2.2存储本地
        localStorage.setItem("UUIDTOKEN", uuid_token)
    }
    //当用户有uuid时就不会再生成
    return uuid_token
}